:art: IsolationPointUserInfo.HAS_NOT/YET_UPLOAD

huangqimin001 3 years ago
parent
commit
d0c148e111
2 changed files with 9 additions and 6 deletions
  1. 3 3
      api/eqpt_views.py
  2. 6 3
      equipment/models.py

+ 3 - 3
api/eqpt_views.py

@@ -134,7 +134,7 @@ def eqpt_result(request):
134 134
     ipuis = [ipui.data for ipui in ipuis]
135 135
 
136 136
     total_active_eqpt_num = eqpts.count()
137
-    has_upload_temperature_num = len([1 for ipui in ipuis if ipui.get('temperature_has_upload', '') == '已上报'])
137
+    has_upload_temperature_num = len([1 for ipui in ipuis if ipui.get('temperature_has_upload', '') == IsolationPointUserInfo.HAS_YET_UPLOAD])
138 138
     fever_num = len([1 for ipui in ipuis if ipui.get('temperature', 0) > settings.FEVER_TEMPERATURE])
139 139
 
140 140
     ipuis = {ipui.get('pk'): {
@@ -181,7 +181,7 @@ def get_screen_data(point=None, point_id=None):
181 181
     ipuis = [ipui.data for ipui in ipuis]
182 182
 
183 183
     total_active_eqpt_num = eqpts.count()
184
-    has_upload_temperature_num = len([1 for ipui in ipuis if ipui.get('temperature_has_upload', '') == '已上报'])
184
+    has_upload_temperature_num = len([1 for ipui in ipuis if ipui.get('temperature_has_upload', '') == IsolationPointUserInfo.HAS_YET_UPLOAD])
185 185
     fever_num = len([1 for ipui in ipuis if ipui.get('temperature', 0) > settings.FEVER_TEMPERATURE])
186 186
 
187 187
     ipuis = {ipui.get('pk'): {
@@ -229,7 +229,7 @@ def get_screen_data(point=None, point_id=None):
229 229
         temperature = eqpt.get('temperature')
230 230
         if temperature > settings.FEVER_TEMPERATURE:
231 231
             eqpts_fever.append(eqpt)
232
-        elif has_upload == '未上报' and temperature <= settings.FEVER_TEMPERATURE:
232
+        elif has_upload == IsolationPointUserInfo.HAS_NOT_UPLOAD and temperature <= settings.FEVER_TEMPERATURE:
233 233
             eqpts_not_upload.append(eqpt)
234 234
         else:
235 235
             eqpts_other.append(eqpt)

+ 6 - 3
equipment/models.py

@@ -136,6 +136,9 @@ class IsolationPointInfo(BaseModelMixin):
136 136
 
137 137
 
138 138
 class IsolationPointUserInfo(BaseModelMixin):
139
+    HAS_NOT_UPLOAD = '未上报'
140
+    HAS_YET_UPLOAD = '已上报'
141
+
139 142
     point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True)
140 143
 
141 144
     user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户唯一标识', db_index=True)
@@ -166,10 +169,10 @@ class IsolationPointUserInfo(BaseModelMixin):
166 169
     @property
167 170
     def temperature_has_upload(self):
168 171
         if not self.last_submit_at:
169
-            return '未上报'
172
+            return IsolationPointUserInfo.HAS_NOT_UPLOAD
170 173
         if self.last_submit_at > tc.utc_datetime(hours=-1):
171
-            return '已上报'
172
-        return '未上报'
174
+            return IsolationPointUserInfo.HAS_YET_UPLOAD
175
+        return IsolationPointUserInfo.HAS_NOT_UPLOAD
173 176
 
174 177
     @property
175 178
     def data(self):